package com.dpwgc.provider.config;

import com.dpwgc.provider.utils.DateUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.MessagingException;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * 定时任务
 */
@Configuration//兼备Component的效果
@EnableScheduling//定时任务开启
@EnableAsync//多线程开启
public class TimeTaskConfig {

    //添加定时任务
    //@Scheduled(cron = "0/5 * * * * ?")//每五秒执行
    @Scheduled(cron = "0 0 21 ? * SAT")//每周六9点执行

    //执行操作
    private void configureTasks() throws MessagingException {

        DateUtil dateUtil = new DateUtil();
        System.err.println("定时任务执行成功 |"+" 执行时间: " +dateUtil.getDateTime());
    }
}


